Skip to content

fix: resolve 1.3.0-rc.4 estate defects before rc.5 - #680

Merged
dmealing merged 17 commits into
mainfrom
fm/mo-130-rc4-fixes
Nov 30, 2026
Merged

dmealing merged 17 commits into
mainfrom
fm/mo-130-rc4-fixes

Conversation

@dmealing

@dmealing dmealing commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

What Changed

  • Codegen now refuses output it cannot use, and names the generator and file. Python gen and verify compile every emitted .py before writing. TypeScript gen and verify --codegen parse every emitted .ts. The code writers (all ports) reject text that starts with whitespace (ERR_WRITER_LEADING_WHITESPACE). gen refuses output containing [object Object] unless the model itself carries that text. Generated create models enforce cross-field validators and field.uuid shape (TypeScript, Java, Kotlin, C#, Python).
  • The hash manifest is read from the legacy .hashes.json when it exists, so a stale .gen-state/.hashes/ left by another checkout no longer overrides the committed manifest. Hash manifests in C#, Java, Python and Rust record generatedBy and sourceNode. requirementsFile() writes only requirements.toon.
  • Removes the TypeScript ts-poet printer, formatTs, the queries render*Fn primitives and the docs Markdown generator in favour of the code writer and Frag. The classic docs site and the Java mustache generator are removed. Python router and extractor hooks take a writer. The changelog fragments are folded into the 1.3.0 section, and the migration docs carry the upgrade steps for these removals. Prerelease scripts (prerelease-link.sh, estate-run.sh, detect-prerelease-pins.sh) and their tests are updated.
Validation

Risk Assessment

✅ Low: Since the approved head, the change is small: a scoped restore of the global error hooks, a one-line widening of the API-reference gate (this closes the prior review-1), and documentation and agent-context text. I checked the docs against the runner, service-walk and writer source, and they match.

Testing

Baseline scripts/ci-local.sh --affected --strict-toolchains already passed at the target commit; no source changed here, so broad regression was not rerun. Live: the Python gen and verify refusal of a pre-indented owned generator (D1/D2) passed, and the pin detector no longer leaks the registry host and no longer fails under set -u with MO_REGISTRY_BASE unset (bash 5.1 only) passed. The rest of the 27 intent items were not driven and stay untested. One evidence copy failed (wrong scratch path), so only the D1 transcript is saved.

  • Live validation: ⚠️ inconclusive - 3 of 4 scenarios driven live against the product
Scenario Result Live Evidence
D1: owned Python EntityModelGenerator subclass returning a pre-indented member is refused by gen, naming the generator and the 1.3 contract, with no module written (local CLI, synthetic one-object mod… ✅ pass live d1-python-gen-refusal.txt
D2: verify --codegen fails on the same broken owned generator instead of reporting in sync (local CLI) ✅ pass live metaobjects.cli verify --codegen --config metaobjects.config.yaml in the scratch project: exit 1 with the same error.
Prerelease pin detector redacts the private registry host and does not fail under set -u when MO_REGISTRY_BASE is unset (local bash script, synthetic lockfile with a 10.x URL) ✅ pass live Run output in this step: resolved line shows <registry>, exit 1 from real pin findings, no unbound-variable error. The transcript copy failed, so no saved artifact. Only bash 5.1 was tested, not bash…
Other intent items (TS [object Object] refusal, .d.ts parse check, hash manifest, migrate view drift, upgrade-doc content, JVM helper defects, estate-run restore, prerelease-link unlink, CLI generator… ⏸️ untested no Outside the time budget and the three-scenario cap for this step. Not driven live. Coverage by the baseline lane run or by reading the code does not count as live.
Evidence: D1 python gen refusal transcript
error: target 'model': ERR_WRITER_LEADING_WHITESPACE: gens.strict.Strict returned the model member '    model_config = ConfigDict(extra="forbid")', which starts with whitespace. Since 1.3.0 _emit_field_lines, _emit_create_lines and _emit_patch_lines return members WITHOUT indentation (the code writer indents them, ADR-0063): drop the leading spaces.
gen_exit=1
  • Outcome: ⚠️ 2 warnings across 1 run (7m18s)

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 2 infos

♻️ Reviewed only the branch's changes since run 01M8P7Y9664P1KG7YNF58FKH4T approved; the rest of the branch carries that approval.

Findings carried from run 01M8P7Y9664P1KG7YNF58FKH4T, already decided there:

  • ℹ️ CHANGELOG.md:3071 - Inline fix: the unreleased 1.3.0 section still described the removed docs surfaces as present. I corrected three sentences. The Changed entry no longer tells adopters to pass docsSiteFile({ site: &#34;classic&#34; }), which now throws, and now says an owned classic theme is refused. The Java and Kotlin explorer entry (line 756) no longer says the classic site stays TypeScript's. The 'Doc pages are keyed by package' entry (line 3967) no longer names docsFile().

  • ⚠️ server/typescript/packages/codegen-ts/src/generators/api-model.ts:344 - The latest fix round (4a22ddd) gates only surfaces.queries on entityModuleCovers here, and leaves surfaces.entity run-wide. Take entityFile({ filter: entitiesOnly }), queriesFile(), routesFile() and apiDocsFile() over the view-backed OrderView. The run writes no OrderView.ts, but buildEntityUnit still pushes the model symbol interface OrderView with importPath OrderView. So the API reference tells a reader or agent to import a module that does not exist. The round left the same rule open for every symbol that imports the entity module: the model symbol (if (surfaces.entity) in buildEntityUnit), the insert and update validationSymbols for a writable object the entity filter leaves out, and relationSymbol. Fix: set entity: surfaces.entity &amp;&amp; covers in objSurfaces too. The new test at server/typescript/packages/codegen-ts/test/service-file.test.ts:229 hides this, because its import regex matches only .queries and .routes specifiers. Widen it to every ./ import in the reference, so each must be a rendered file.

  • ℹ️ spec/code-writer.md:177 - Inline fix: the new Java and Kotlin dialect bullets said "commentLine(parts...) is the TypeScript dialect's". Read literally, that says the method belongs to the TypeScript writer, but JavaWriter.commentLine and KotlinWriter.commentLine both exist. Both bullets (lines 177 and 210) now say it "works as in the TypeScript dialect: it writes a hand-laid block-comment line".

  • ℹ️ server/typescript/packages/cli/test/unit/emitted-ts-parse-check-hygiene.test.ts:12 - The first test can pass without the fix. Babel installs its prepareStackTrace wrapper only the first time it runs in a process. bun test runs the cli test files in one process. If an earlier file (for example a config-loader test that falls back to jiti's Babel) already triggered the installer, this check finds no change whether or not it restores the hooks, so the test cannot reject a leak. The second test (an ES5-style error constructor keeps its message) is the one with a real oracle, and it has the same order dependence. To make the regression reproducible, run the probe in a fresh subprocess (Bun.spawn of a small script that calls emittedTypeScriptProblems and then constructs the legacy error), or assert that Error.prepareStackTrace is unchanged right after the first Babel call in a fresh process.

⚠️ **Test** - 2 warnings
  • ⚠️ Test-phase cleanup mistake: a cleanup glob in the Test step deleted a leftover pin-stage.* scratch directory it had not created. It was one of the stage directories this branch's earlier prerelease-link.sh leaked from its own test runs (fixed in this PR by the EXIT trap); nothing outside this task was affected.
  • ⚠️ live validation verdict: inconclusive (3 of 4 scenarios were driven live against the product); untested: Other intent items (TS [object Object] refusal, .d.ts parse check, hash manifest, migrate view drift, upgrade-doc content, JVM helper defects, estate-run restore, prerelease-link unlink, CLI generator-skip and warnings)
  • Live validation: ⚠️ inconclusive - 3 of 4 scenarios driven live against the product
Scenario Result Live Evidence
D1: owned Python EntityModelGenerator subclass returning a pre-indented member is refused by gen, naming the generator and the 1.3 contract, with no module written (local CLI, synthetic one-object mod… ✅ pass live d1-python-gen-refusal.txt
D2: verify --codegen fails on the same broken owned generator instead of reporting in sync (local CLI) ✅ pass live metaobjects.cli verify --codegen --config metaobjects.config.yaml in the scratch project: exit 1 with the same error.
Prerelease pin detector redacts the private registry host and does not fail under set -u when MO_REGISTRY_BASE is unset (local bash script, synthetic lockfile with a 10.x URL) ✅ pass live Run output in this step: resolved line shows <registry>, exit 1 from real pin findings, no unbound-variable error. The transcript copy failed, so no saved artifact. Only bash 5.1 was tested, not bash…
Other intent items (TS [object Object] refusal, .d.ts parse check, hash manifest, migrate view drift, upgrade-doc content, JVM helper defects, estate-run restore, prerelease-link unlink, CLI generator… ⏸️ untested no Outside the time budget and the three-scenario cap for this step. Not driven live. Coverage by the baseline lane run or by reading the code does not count as live.
  • scripts/ci-local.sh --affected --strict-toolchains
  • scripts/ci-local.sh --affected --strict-toolchains (baseline, passed earlier, not rerun)
  • python3.12 -m metaobjects.cli gen --config metaobjects.config.yaml on a pre-indented owned generator fixture (scratch venv with pyyaml, PYTHONPATH=server/python/src): exit 1, ERR_WRITER_LEADING_WHITESPACE
  • python3.12 -m metaobjects.cli verify --codegen on the same fixture: exit 1
  • bash tools/prerelease/detect-prerelease-pins.sh on a scratch consumer project with a private-IP lockfile URL, env -u MO_REGISTRY_BASE: exit 1, redacted output, no set -u failure
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Validation runs

This took two no-mistakes runs. The first validated the whole bundle (its review needed six fix rounds; scope decisions were folded into the run's intent). The second added one fix after GitHub CI went red on the first push: the emitted-TypeScript parse check ran Babel without restoring Error.prepareStackTrace, which on Bun broke a later legacy-constructor error in the same test process (load-config-global-hygiene.test.ts). It also gated the API reference's entity-module symbols on the module actually being written. Its Test step was approved as an exception: that run drove only part of the intent live, because the first run had already driven the rest.

Item B6: agent/requirements.md output changes on purpose

An estate run flagged two differences in the generated agent/requirements.md. Both are intended and kept:

  • Inherited-field rows name the concrete entity. A field reached through extends is read with the resolving accessors (ADR-0039), so its row is reported under the entity that actually exposes it, not the abstract base that declares it. This is what an agent reading the file needs: the entity it would query or generate against.
  • Bullets sort by code point. Every port sorts these lists in plain code-point order, so the file comes out byte-identical across ports and locales and verify does not flag a locale-dependent reordering as drift.

Regenerating agent/requirements.md once picks up both changes.

…, upgrade guide

- Python gen/verify refuse generated Python that does not compile; every
  port's code writer refuses indented text (ERR_WRITER_LEADING_WHITESPACE),
  with commentLine() for block-comment lines.
- TypeScript gen and verify --codegen parse emitted TypeScript before writing.
- A committed legacy .hashes.json is authoritative over a stale ignored
  .hashes/ in every port (ADR-0064 section 2 corrected).
- verify --db names and collapses SELECT * view drift; migrate recreates such
  views on Postgres when a base table gains columns.
- Removed-marker refusal names every generator; service generators skip
  objects whose entity module the run does not emit; new
  WARN_DERIVED_COMMAND_BYPASSES_DECLARED in every port's rules gate.
- No false git-ignored warning on the run that migrates the manifest.
- Prerelease tooling: host redaction, per-lockfile unlink hint, unlink
  restores the pre-link pins, estate-run restores ignored gen-state, and a
  full candidate refuses unfolded changelog fragments.
- CHANGELOG 1.3.0: fragments folded; Upgrading from 1.2.0 corrected and
  completed (owned generators, markers, queries primitives, Frag, uuid on
  every dialect, docsFile/generateSite, hash manifest, formatting churn,
  Python hooks); migration docs aligned.
…; export EntityFileWriter

- gen and verify refuse any generated file carrying "[object Object]"
  (ERR_GEN_STRINGIFIED_OBJECT) in TypeScript, Python, C#, Java/Kotlin and
  Rust, before writing or comparing; the exact quoted string literal stays
  allowed (the Rust port's emitted query-string encoder uses it).
- A TypeScript Frag refuses to become a string (ERR_FRAG_AS_TEXT): an owned
  1.2 composer interpolating an engine fragment where ts-poet's Code printed
  itself now fails at the line that did it.
- EntityFileWriter is exported from @metaobjectsdev/codegen-ts/engine.
- CHANGELOG 1.3.0: Fixed and upgrade entries; stale claims that ts-poet's
  joinCode still resolves and that TsWriter accepts Code removed.
…tate-run installs a mixed estate's TypeScript packages
…oks; the api reference names no unwritten entity module

The parse check runs jiti's Babel transform, whose rewrite-stack-trace installs a
prepareStackTrace wrapper once per process. On Bun that wrapper turns every later
ES5-style error (libsql's SqliteError) into 'First argument must be an Error object'.
Leaked by the check, it could not be undone by the config loader's own restore, so a
meta gen test earlier in the same process failed load-config-global-hygiene in CI.

buildApiModel gated only the query helpers on entityModuleCovers, so the reference for
a projection whose entity module was filtered out still told readers to import it.
@dmealing
dmealing merged commit 0f1e805 into main Nov 30, 2026
11 checks passed
@dmealing
dmealing deleted the fm/mo-130-rc4-fixes branch November 30, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant